package com.smap.control;

import com.smap.core.Control;
import com.smap.core.Map;
import com.smap.event.MapEvent;

public abstract class AbstractControl implements Control {

	Map map;
	ToolBar toolBar;
	public boolean isActive = false;

	public void install(Map map) {
		this.map = map;
		toolBar = map.getToolBar();
	}

	public void activate() {
		isActive = true;
	}

	public void deActivate() {
		isActive = false;
	}

	public void onMapEvent(MapEvent mapEvent) {
		if (isActive && !mapEvent.stop) {
			onEvent(mapEvent);
		}
	}

	abstract void onEvent(MapEvent mapEvent);

}
